package com.zhzhinn.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.edgclub.edg.R;
import com.edgclub.edg.adapter.adapteruitls.GzBaseAdapter;
import com.edgclub.edg.adapter.adapteruitls.MyItemClickListener;
import com.edgclub.edg.adapter.adapteruitls.MyItemLongClickListener;
import com.edgclub.edg.adapter.adapteruitls.RViewHolder;
import com.edgclub.edg.model.Topic;
import com.edgclub.edg.uc.UnableScrollGridView;
import com.edgclub.edg.utils.GlideUtil.GlideUtils;
import com.rockerhieu.emojicon.EmojiconTextView1;

import java.util.List;

/**
 */
public class InnAdapter extends GzBaseAdapter{
    private List<Topic> datas = null;
    private Context mContext;
    private GlideUtils glideUtils;


    public InnAdapter(Context context) {
        this.mContext = context;

    }


    //创建新View，被LayoutManager所调用
    @Override
    public InnAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.zz_item_inn,viewGroup,false);
        ViewHolder vh = new ViewHolder(view,mListener,mLongClickListener);
        return vh;
    }

    //将数据与界面进行绑定的操作
    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder viewHolder1, final int position) {
        final InnAdapter.ViewHolder viewHolder= (ViewHolder) viewHolder1;
        final Topic topic =datas.get(position);


    }


    //获取数据的数量
    @Override
    public int getItemCount() {
        if(datas==null)return 0;
        return datas.size();
    }

    public List<Topic> getDatas() {
        return datas;
    }

    public void setDatas(List<Topic> datas) {
        this.datas = datas;
    }

    //自定义的ViewHolder，持有每个Item的的所有界面元素
    public static class ViewHolder extends RViewHolder {
        private EmojiconTextView1 topic_content;
        private TextView topic_time,user_name,topic_unsee_del;
        private TextView tv_comment_count,tv_zan_count;
        private ImageView user_icon,red_icon,imgv_digest,isvip,imgv_zan,imgv_star1,imgv_star2,imgv_banner;
        private UnableScrollGridView unableScrollGridView;
        //语音
        ImageView iv_voice, iv_voice_bg;
        RelativeLayout ll_voice;
        TextView tv_length;
        FrameLayout topic_all_layout;
        //
        LinearLayout ll_zan,ll_comment,unsee_layout,ll_banner;

        public ViewHolder(View view, MyItemClickListener mListener, MyItemLongClickListener mLongClickListener){
            super(view,mListener,mLongClickListener);
            topic_content = (EmojiconTextView1) view.findViewById(R.id.topic_content);
            topic_time = (TextView) view.findViewById(R.id.topic_time);
            user_name = (TextView) view.findViewById(R.id.user_name);
            tv_zan_count = (TextView) view.findViewById(R.id.tv_zan_count);
            tv_comment_count = (TextView) view.findViewById(R.id.tv_comment_count);
            user_icon = (ImageView) view.findViewById(R.id.user_icon);
            red_icon = (ImageView) view.findViewById(R.id.red_icon);
            imgv_digest = (ImageView) view.findViewById(R.id.imgv_digest);
            unableScrollGridView = (UnableScrollGridView) view.findViewById(R.id.unableScrollGridView);
            iv_voice = (ImageView) view.findViewById(R.id.iv_voice);
            iv_voice_bg = (ImageView) view.findViewById(R.id.iv_voice_bg);
            ll_voice = (RelativeLayout) view.findViewById(R.id.ll_voice);
            tv_length = (TextView) view.findViewById(R.id.tv_length);
            ll_zan = (LinearLayout) view.findViewById(R.id.ll_zan);
            imgv_zan = (ImageView) view.findViewById(R.id.imgv_zan);
            imgv_star1 = (ImageView) view.findViewById(R.id.imgv_star1);
            imgv_star2 = (ImageView) view.findViewById(R.id.imgv_star2);
            ll_comment = (LinearLayout) view.findViewById(R.id.ll_comment);
            unsee_layout = (LinearLayout) view.findViewById(R.id.unsee_layout);
            topic_all_layout = (FrameLayout) view.findViewById(R.id.topic_all_layout);
            topic_unsee_del= (TextView) view.findViewById(R.id.topic_unsee_del);
            isvip= (ImageView) view.findViewById(R.id.isvip);

            ll_banner = (LinearLayout) view.findViewById(R.id.ll_banner);
            imgv_banner = (ImageView) view.findViewById(R.id.imgv_banner);

        }
    }

}
